var cityNo;
var compantyId;
var sexId = '';
var historyNo = 0 ;
var testNo;
var channelIdId = "undefined";
$(function(){
    // sessionStorage.clear();
    //全局变量
    var cityCode;
    var compantyTypeCode;
    var compantyNameCode;
    var nameCode;
    var sexCode;
    var sfCode;
    var jszCode;
    var carCode;
    var recordCode;
   
    //接受url传参 userId
    var userId;
    userId = getQueryStr("userId");
    // 接受后储存userId
    sessionStorage.setItem("userIdName",userId);

    //下一页面再返回时候数据渲染
    testNo = sessionStorage.getItem("historyStorage");
    if(testNo == 1){
         historyNo = testNo;
    }

    //判断其登陆方式：二维码 QRCodeId, 非二维码 undefined.
    var QRCodeId;
    QRCodeId=sessionStorage.getItem("QRCodeHistory");
    if(QRCodeId==""){
        channelIdId = "undefined";
    }else if(QRCodeId !== ""){
        channelIdId =QRCodeId;    
    }

    //访问接口 判断此userId是否有数据
    $.ajax({
            type: "post",
            url:baseUrl+"/dingding-web/driverAction!getDriverAuthInfo.action",
            dataType: "jsonp",
            async: false,
            jsonp: "callback",
            jsonpCallback: "success_jsonp",
            data:{
                userId:userId
            },
            success: function(data){ 
                console.log(data);
            sessionStorage.setItem("storageInformation",data);  
            if(data.code == 200&&channelIdId == "undefined"){  /*申请过数据且非二维码方式*/
             getCityName();
             var cityName = data.responseBody.cityName;
             cityNo = data.responseBody.cityId;
             var compantyName = data.responseBody.organizationName;
             compantyId =  data.responseBody.organizationId;
             var driverName = data.responseBody.trueName;
             sexId = data.responseBody.sex;

             var idCard = data.responseBody.idCard;
             var driLicDate = data.responseBody.jszLssueDate;
             var driLicDateLast = data.responseBody.jszValidityPeriod;
             var carType = data.responseBody.permittedType;
             var licDataNo = data.responseBody.jszFileNumber; 
             var typeNum = data.responseBody.authType;

             $(".city_btn").attr("placeholder","");                                       
             $(".city_btn").attr("value",cityName);
             $(".companty_type").attr("placeholder","");                                       
             $(".companty_type").attr("value",compantyName);
             $(".driver_name").attr("placeholder","");
             $(".driver_name").attr("value",driverName);
             if(sexId == 1){
                $(".sex").attr("placeholder","");
                $(".sex").attr("value","男");
             }else if(sexId == 2){
                $(".sex").attr("placeholder","");
                $(".sex").attr("value","女");
             }
             
             $(".sfNumber").attr("placeholder","");
             $(".sfNumber").attr("value",idCard);
             $(".jszDate").attr("placeholder","");
             $(".jszDate").attr("value",driLicDate);
             $(".jszDateLast").attr("placeholder","");
             $(".jszDateLast").attr("value",driLicDateLast);
             $(".carList").attr("placeholder","");
             $(".carList").attr("value",carType);
             $(".recordNum").attr("placeholder","");
             $(".recordNum").attr("value",licDataNo);  
             $("input[numbercode='"+typeNum+"']").attr("checked",true);         
             $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
             $(".carBtn").attr("disabled",false);
            
             $(".carBtn").on("click",function(){
                    sessionStorage.setItem("userIdName",userId);
                    //页面下一步前数据保存
                    sessionStorage.setItem("cityName",cityNo);
                    sessionStorage.setItem("compantyType",compantyId);
                    sessionStorage.setItem("name",$(".driver_name").attr("value"));
                    sessionStorage.setItem("sex",sexId);
                    sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                    sessionStorage.setItem("driLicDate",$(".jszDate").val());
                    sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                    sessionStorage.setItem("carType",$(".carList").attr("value"));
                    sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                    sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));

                    if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 ){
                        window.location.href="speciallyCarInformation.html";
                    }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3){
                        window.location.href="taxiCarInformation.html";
                    }
                    
             })

             }else if(data.code ==  600&&channelIdId == "undefined"){ /*未申请过数据且非二维码方式*/
                //返回上一页面数据保存操作
                if(historyNo == 1){
                    //调用获取城市函数方法
                    getCityName();
                    var cityNameHistory = sessionStorage.getItem("cityHistory");
                    var compantyNameHistory = sessionStorage.getItem("compantyHistory");
                    var driverNameHistory = sessionStorage.getItem("name");
                    var sexIdHistory = sessionStorage.getItem("sexNameHistory");
                    var idCardHistory = sessionStorage.getItem("idCard");
                    var driLicDateHistory = sessionStorage.getItem("driLicDate");
                    var driLicDateLastHistory = sessionStorage.getItem("lastDate");
                    var carTypeHistory = sessionStorage.getItem("carType");
                    var licDataNoHistory = sessionStorage.getItem("licDataNo");
                    var typeNumHistory = sessionStorage.getItem("typeNum");
                     $(".city_btn").attr("placeholder","");                                       
                     $(".city_btn").attr("value",cityNameHistory);
                     $(".companty_type").attr("placeholder","");                                       
                     $(".companty_type").attr("value",compantyNameHistory);
                     $(".driver_name").attr("placeholder","");
                     $(".driver_name").attr("value",driverNameHistory);
                     $(".sex").attr("placeholder","");
                     $(".sex").attr("value",sexIdHistory);
                     $(".sfNumber").attr("placeholder","");
                     $(".sfNumber").attr("value",idCardHistory);
                     $(".jszDate").attr("placeholder","");
                     $(".jszDate").attr("value",driLicDateHistory);
                     $(".jszDateLast").attr("placeholder","");
                     $(".jszDateLast").attr("value",driLicDateLastHistory);
                     $(".carList").attr("placeholder","");
                     $(".carList").attr("value",carTypeHistory);
                     $(".recordNum").attr("placeholder","");
                     $(".recordNum").attr("value",licDataNoHistory);  
                     $("input[numbercode='"+typeNumHistory+"']").attr("checked",true);         
                     $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
                     $(".carBtn").attr("disabled",false);

                     $(".carBtn").on("click",function(){
                        cityCode = $(".city_btn").val();
                        compantyTypeCode = $(".companty_type").val();
                        nameCode = $(".driver_name").val();
                        sexCode = $(".sex").val();
                        sfCode = $(".sfNumber").val();
                        jszCode = $(".jszDate").val();
                        jszLastCode = $(".jszDateLast").val();
                        carCode = $(".carList").val();
                        recordCode = $(".recordNum").val();
                        //页面下一步前数据保存
                        var cityNameHistoryId = sessionStorage.getItem("cityName");
                        sessionStorage.setItem("cityName",cityNameHistoryId);

                        var compantyTypeHistoryId = sessionStorage.getItem("compantyType");
                        sessionStorage.setItem("compantyType",compantyTypeHistoryId);
                        sessionStorage.setItem("name",$(".driver_name").attr("value"));

                        var sexHistoryId = sessionStorage.getItem("sex");
                        sessionStorage.setItem("sex",sexHistoryId);

                        sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                        sessionStorage.setItem("driLicDate",$(".jszDate").val());
                        sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                        sessionStorage.setItem("carType",$(".carList").attr("value"));
                        sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                        sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));
                        //history 上一步
                        sessionStorage.setItem("cityHistory",$(".city_btn").val());
                        sessionStorage.setItem("compantyHistory",$(".companty_type").val());
                        sessionStorage.setItem("sexNameHistory",$(".sex").val());

                        if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 &&cityCode!==""&&compantyTypeCode!==""&&nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            window.location.href="speciallyCarInformation.html";
                        }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3&&cityCode!==""&&compantyTypeCode!==""&&nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            window.location.href="taxiCarInformation.html";
                        }else{
                            swal({
                                title: "请填写完毕所有相关信息",
                                type: "warning",
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "确定",
                            });
                         }
                        
                    })
                }else if(historyNo == 0){  
                    //调用获取城市函数方法
                    getCityName();
                    //监听事件控制button 激活及其颜色控制
                    $('input').bind('input propertychange', function() {
                        cityCode = $(".city_btn").val();
                        compantyTypeCode = $(".companty_type").val();
                        nameCode = $(".driver_name").val();
                        sexCode = $(".sex").val();
                        sfCode = $(".sfNumber").val();
                        jszCode = $(".jszDate").val();
                        jszLastCode = $(".jszDateLast").val();
                        carCode = $(".carList").val();
                        recordCode = $(".recordNum").val();
                        if(cityCode!==""&&compantyTypeCode!==""&&nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
                            $(".carBtn").attr("disabled",false);
                        }
                        else if(cityCode==""||compantyTypeCode==""||nameCode==""||sexCode==""||sfCode==""||jszCode==""||carCode==""||recordCode==""||jszLastCode==""){
                            $(".carBtn").css({"background":"gray","color":"white"});
                            $(".carBtn").attr("disabled",true);
                        } 
                    });

                    $(".carBtn").on("click",function(){
                        //页面下一步前数据保存                    
                        sessionStorage.setItem("name",$(".driver_name").attr("value"));                            
                        sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                        sessionStorage.setItem("driLicDate",$(".jszDate").val());
                        sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                        sessionStorage.setItem("carType",$(".carList").attr("value"));
                        sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                        sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));
                        //history 上一步
                        sessionStorage.setItem("cityHistory",$(".city_btn").val());
                        sessionStorage.setItem("compantyHistory",$(".companty_type").val());
                        sessionStorage.setItem("sexNameHistory",$(".sex").val());

                        if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 ){
                            sessionStorage.setItem("historyStorage",1);
                            window.location.href="speciallyCarInformation.html";
                        }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3){
                            sessionStorage.setItem("historyStorage",1);
                            window.location.href="taxiCarInformation.html";
                        }
                        
                    })
                }
                

             }else if(data.code == 200 && channelIdId !== "undefined"){ /*申请过数据且为二维码方式*/
                 //二维码方式：城市,公司名字display   
                 $(".cityBox").css("display","none");
                 $(".companyNameBox").css("display","none");

                 var driverName = data.responseBody.trueName;
                 sexId = data.responseBody.sex;

                 var idCard = data.responseBody.idCard;
                 var driLicDate = data.responseBody.jszLssueDate;
                 var driLicDateLast = data.responseBody.jszValidityPeriod;
                 var carType = data.responseBody.permittedType;
                 var licDataNo = data.responseBody.jszFileNumber; 
                 var typeNum = data.responseBody.authType;

                 $(".driver_name").attr("placeholder","");
                 $(".driver_name").attr("value",driverName);
                 if(sexId == 1){
                    $(".sex").attr("placeholder","");
                    $(".sex").attr("value","男");
                 }else if(sexId == 2){
                    $(".sex").attr("placeholder","");
                    $(".sex").attr("value","女");
                 }
                 
                 $(".sfNumber").attr("placeholder","");
                 $(".sfNumber").attr("value",idCard);
                 $(".jszDate").attr("placeholder","");
                 $(".jszDate").attr("value",driLicDate);
                 $(".jszDateLast").attr("placeholder","");
                 $(".jszDateLast").attr("value",driLicDateLast);
                 $(".carList").attr("placeholder","");
                 $(".carList").attr("value",carType);
                 $(".recordNum").attr("placeholder","");
                 $(".recordNum").attr("value",licDataNo);  
                 $("input[numbercode='"+typeNum+"']").attr("checked",true);         
                 $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
                 $(".carBtn").attr("disabled",false);
                

                 $(".carBtn").on("click",function(){
                        sessionStorage.setItem("userIdName",userId);
                        //页面下一步前数据保存
                        sessionStorage.setItem("name",$(".driver_name").attr("value"));
                        sessionStorage.setItem("sex",sexId);
                        sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                        sessionStorage.setItem("driLicDate",$(".jszDate").val());
                        sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                        sessionStorage.setItem("carType",$(".carList").attr("value"));
                        sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                        sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));

                        if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 ){
                            window.location.href="speciallyCarInformation.html";
                        }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3){
                            window.location.href="taxiCarInformation.html";
                        }
                        
                 })

             }else if(data.code == 600 && channelIdId !== "undefined"){ /*未申请过数据且为二维码方式*/
                 //二维码方式：城市,公司名字display   
                 $(".cityBox").css("display","none");
                 $(".companyNameBox").css("display","none");

                 if(historyNo == 1){
                    var driverNameHistory = sessionStorage.getItem("name");
                    var sexIdHistory = sessionStorage.getItem("sexNameHistory");
                    var idCardHistory = sessionStorage.getItem("idCard");
                    var driLicDateHistory = sessionStorage.getItem("driLicDate");
                    var driLicDateLastHistory = sessionStorage.getItem("lastDate");
                    var carTypeHistory = sessionStorage.getItem("carType");
                    var licDataNoHistory = sessionStorage.getItem("licDataNo");
                    var typeNumHistory = sessionStorage.getItem("typeNum");
                     $(".driver_name").attr("placeholder","");
                     $(".driver_name").attr("value",driverNameHistory);
                     $(".sex").attr("placeholder","");
                     $(".sex").attr("value",sexIdHistory);
                     $(".sfNumber").attr("placeholder","");
                     $(".sfNumber").attr("value",idCardHistory);
                     $(".jszDate").attr("placeholder","");
                     $(".jszDate").attr("value",driLicDateHistory);
                     $(".jszDateLast").attr("placeholder","");
                     $(".jszDateLast").attr("value",driLicDateLastHistory);
                     $(".carList").attr("placeholder","");
                     $(".carList").attr("value",carTypeHistory);
                     $(".recordNum").attr("placeholder","");
                     $(".recordNum").attr("value",licDataNoHistory);  
                     $("input[numbercode='"+typeNumHistory+"']").attr("checked",true);         
                     $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
                     $(".carBtn").attr("disabled",false);

                     $(".carBtn").on("click",function(){
                        nameCode = $(".driver_name").val();
                        sexCode = $(".sex").val();
                        sfCode = $(".sfNumber").val();
                        jszCode = $(".jszDate").val();
                        jszLastCode = $(".jszDateLast").val();
                        carCode = $(".carList").val();
                        recordCode = $(".recordNum").val();
                        //页面下一步前数据保存
                        sessionStorage.setItem("name",$(".driver_name").attr("value"));
                        var sexHistoryId = sessionStorage.getItem("sex");
                        sessionStorage.setItem("sex",sexHistoryId);
                        sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                        sessionStorage.setItem("driLicDate",$(".jszDate").val());
                        sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                        sessionStorage.setItem("carType",$(".carList").attr("value"));
                        sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                        sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));
                        //history 上一步
                        sessionStorage.setItem("sexNameHistory",$(".sex").val());

                        if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 &&cityCode!==""&&compantyTypeCode!==""&&nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            window.location.href="speciallyCarInformation.html";
                        }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3&&cityCode!==""&&compantyTypeCode!==""&&nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            window.location.href="taxiCarInformation.html";
                        }else{
                            swal({
                                title: "请填写完毕所有相关信息",
                                type: "warning",
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "确定",
                            });
                         }
                        
                    })
                }else if(historyNo == 0){
                    //监听事件控制button 激活及其颜色控制
                    $('input').bind('input propertychange', function() {
                        nameCode = $(".driver_name").val();
                        sexCode = $(".sex").val();
                        sfCode = $(".sfNumber").val();
                        jszCode = $(".jszDate").val();
                        jszLastCode = $(".jszDateLast").val();
                        carCode = $(".carList").val();
                        recordCode = $(".recordNum").val();
                        if(nameCode!==""&&sexCode!==""&&sfCode!==""&&jszCode!==""&&carCode!==""&&recordCode!==""&&jszLastCode!==""){
                            $(".carBtn").css({"background":"#FF4C4B","color":"#FFFFFF"});
                            $(".carBtn").attr("disabled",false);
                        }
                        else if(nameCode==""||sexCode==""||sfCode==""||jszCode==""||carCode==""||recordCode==""||jszLastCode==""){
                            $(".carBtn").css({"background":"gray","color":"white"});
                            $(".carBtn").attr("disabled",true);
                        } 
                    });

                    $(".carBtn").on("click",function(){
                        //页面下一步前数据保存                    
                        sessionStorage.setItem("name",$(".driver_name").attr("value"));                            
                        sessionStorage.setItem("idCard",$(".sfNumber").attr("value"));
                        sessionStorage.setItem("driLicDate",$(".jszDate").val());
                        sessionStorage.setItem("lastDate",$(".jszDateLast").val())
                        sessionStorage.setItem("carType",$(".carList").attr("value"));
                        sessionStorage.setItem("licDataNo",$(".recordNum").attr("value"));
                        sessionStorage.setItem("typeNum",$('input[name="inlineRadioOptions"]:checked').attr("numberCode"));
                        //history 上一步
                        sessionStorage.setItem("sexNameHistory",$(".sex").val());

                        if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 2 ){
                            sessionStorage.setItem("historyStorage",1);
                            window.location.href="speciallyCarInformation.html";
                        }else if($('input[name="inlineRadioOptions"]:checked').attr("numberCode") == 3){
                            sessionStorage.setItem("historyStorage",1);
                            window.location.href="taxiCarInformation.html";
                        }
                        
                    })
                }
             } 
                 
            }
        });

    //姓名焦点事件
    $(".driver_name").focus(function(){
        $(this).attr("placeholder","");
        $(this).attr("value","");
    });
    $(".driver_name").blur(function(){        
        var driverName = $(".driver_name").val();
        var driNamNumber = /[\u4E00-\u9FA5]{2,4}/;
        if(driNamNumber.test(driverName)){
            $(".driver_name").attr("value",driverName);
        }else{
            $(".driver_name").val("");
            swal({
                title: "请输入您的姓名",
                type: "warning",
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
            });
            $(".driver_name").attr("placeholder","你的中文全名");
        }
    })  

    //性别
    $(".sexType").on("click",function(){
        sexId = $(this).attr("sexId");
        sessionStorage.setItem("sex",sexId);      
        var nms1 = $(this).text().trim();
        $(".sex").attr("value",nms1).attr("placeholder","");
    //取消模态框
        $('#myModal3').modal('hide')
    })


    //身份证信息验证   
    $(".sfNumber").focus(function(){
        $(this).attr("placeholder","");
        $(this).attr("value","");
    });
    $(".sfNumber").blur(function(){
        var identityNumber = $(".sfNumber").val();
        var zzNumber = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/;
        if(zzNumber.test(identityNumber)){
            $(".sfNumber").attr("value",identityNumber);
        }else{
            $(".sfNumber").val("");
            swal({
                title: "请输入正确格式身份证号码",
                type: "warning",
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
            });
            $(".sfNumber").attr("placeholder","请输入身份证号码");
            $(".carBtn").css({"background":"gray","color":"white"});
            $(".carBtn").attr("disabled",true);
        }
    })

    //初次领证日期 日历JS
    var currYear = (new Date()).getFullYear();  
    var opt={};
    opt.date = {preset : 'date'};
    opt.datetime = {preset : 'datetime'};
    opt.time = {preset : 'time'};
    opt.default = {
        theme: 'android-ics light', //皮肤样式
        display: 'modal', //显示方式 
        mode: 'scroller', //日期选择模式
        dateFormat: 'yyyy-mm-dd',
        lang: 'zh',
        showNow: true,
        nowText: "今天",
        startYear: currYear - 50, //开始年份
        endYear: currYear + 10 //结束年份
    };
    $("#appDate").mobiscroll($.extend(opt['date'], opt['default']));
    var optDateTime = $.extend(opt['datetime'], opt['default']);
    var optTime = $.extend(opt['time'], opt['default']);
    $("#appDateTime").mobiscroll(optDateTime).datetime(optDateTime);
    $("#appTime").mobiscroll(optTime).time(optTime);  


    //截止领证日期 日历JS
    var currYear = (new Date()).getFullYear();  
    var opt={};
    opt.date = {preset : 'date'};
    opt.datetime = {preset : 'datetime'};
    opt.time = {preset : 'time'};
    opt.default = {
        theme: 'android-ics light', //皮肤样式
        display: 'modal', //显示方式 
        mode: 'scroller', //日期选择模式
        dateFormat: 'yyyy-mm-dd',
        lang: 'zh',
        showNow: true,
        nowText: "今天",
        startYear: currYear - 50, //开始年份
        endYear: currYear + 10 //结束年份
    };
    $("#appDate1").mobiscroll($.extend(opt['date'], opt['default']));
    var optDateTime = $.extend(opt['datetime'], opt['default']);
    var optTime = $.extend(opt['time'], opt['default']);
    $("#appDateTime").mobiscroll(optDateTime).datetime(optDateTime);
    $("#appTime").mobiscroll(optTime).time(optTime);  


    //准驾车型
    $(".radio").on("click",function(){
        var nms1 = $(this).find(".label_list").text().trim();
        $(".carList").attr("value",nms1).attr("placeholder","");
    //取消模态框
        $('#myModal').modal('hide')
    })
    $(".carDiv").focus(function(){
        $(this).attr("placeholder","");
    });
    $(".carDiv").blur(function(){
        if($(".carDiv").val()==""){         
            $(".carDiv").attr("placeholder","请按驾照信息选择");
        }if($(".carDiv").val()!=="")
        {
            $(".carDiv").attr("placeholder","");
        }
    })  
    var car_z = $(".carDiv").val();
    $(".carDiv").attr("value",car_z); 

    //档案编码
    $(".recordNum").focus(function(){
        $(this).attr("placeholder","");
        $(this).val("");
    });
    $(".recordNum").blur(function(){
        var fileNumber = $(".recordNum").val();
        var fileNumberZ = /\b\d{12}\b/;
        if(fileNumberZ.test(fileNumber)){
            $(".recordNum").attr("value",fileNumber);
        }else{
            $(".recordNum").val("");
            swal({
                title: "请输入正确格式档案编号",
                type: "warning",
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
            });
            $(".recordNum").attr("placeholder","请输入正确的档案编号");
            $(".recordNum").val("");
            // $(".carBtn").css({"background":"gray","color":"white"});
            // $(".carBtn").attr("disabled",true);
        }
    })  

})

//封装选择驾驶证类型弹框方法
function mtTest(){
    $('#myModal').modal('show');
}

//封装选择城市类型弹框方法
function mtTest1(){
    $('#myModal1').modal('show');
}

//封装公司性质弹框方法
function mtTest2(){
    $('#myModal2').modal('show');
}
// //封装性别弹框方法
function mtTest3(){
    $('#myModal3').modal('show');
}

function getCityName(){
    //获取城市列表方法
    $.ajax({
        type: "post",
        url: baseUrl+"/dingding-web/cityAction!getCityList.action",
        dataType: "jsonp",
        async: false,
        jsonp: "callback",
        jsonpCallback: "success_jsonp",
        data: {
        },
        success:function(data){   
            var tpl = document.getElementById("tpl").innerHTML;
            var html =juicer(tpl,data);
            $(".modal-cityList").html(html);

            //期待工作城市
            $(".city_list").on("click",function(){
                var nms1 = $(this).text().trim();              
                $(".city_btn").attr("value",nms1).attr("placeholder","");
            //取消模态框
                $('#myModal1').modal('hide');
                cityNo = $(this).attr("cityId");
                sessionStorage.setItem("cityName",cityNo);
            })
            
        }
    });

    //获取公司性质
    $(".companty_type").on("click",function(){
        $(".modal-compantyTyte").html("");
        $.ajax({
            type: "post",
            url: baseUrl+"/dingding-web/companyAction!getCompanyList.action",
            dataType: "jsonp",
            async: false,
            jsonp: "callback",
            jsonpCallback: "success_jsonp",
            data: {
                cityId:cityNo
            },
            success:function(data){                          
                var tpl = document.getElementById("tpl1").innerHTML;
                var html =juicer(tpl,data);
                $(".modal-compantyTyte").html(html);
                //公司性质
                $(".compantyType").on("click",function(){
                    compantyId= $(this).attr("compantyId");
                    sessionStorage.setItem("compantyType",compantyId);
                    var nms1 = $(this).text().trim();
                    $(".companty_type").attr("value",nms1).attr("placeholder","");
                //取消模态框
                    $('#myModal2').modal('hide')
                })
            }
        }); 
    })
}